package com.dgut.smart_house.service.impl;

import com.dgut.smart_house.domain.Device;
import com.dgut.smart_house.domain.KeyCard;
import com.dgut.smart_house.mapper.KeyCardMapper;
import com.dgut.smart_house.withHardware.SocketCompent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class AsyncService {

    @Autowired
    private SocketCompent socketCompent;
    @Autowired
    private KeyCardMapper keyCardMapper;
    //异步调用如下方法
    @Async
    public Integer asynCreateCardMethod(KeyCard keyCard, Device device){
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        socketCompent.getHardwareSocket().sendMsg(device.getCommand());
        return 1;
    }
}
